package fr.labri.macchiato.framework.business.service;

import fr.labri.macchiato.framework.business.finder.BusinessEntityFinder;
import fr.labri.macchiato.framework.business.finder.ProductFinder;
import fr.labri.macchiato.framework.business.model.preferences.UserPreferences;
import fr.labri.macchiato.framework.business.model.project.Project;
import fr.labri.macchiato.framework.technical.repository.TransientRepository;

/**
 * Factory for the transient services, which persists only for the session.
 * While created or chosen, the user cannot retrieve the info completed in Macchiato
 * 
 * @author Michelle AVOMO
 * 
 */

public class TransientServiceFactory implements ServiceFactory {

	@Override
	public PreferencesService newPreferencesService() {
		TransientRepository<UserPreferences, String> preferencesRepository = new TransientRepository<UserPreferences, String>();
		return new PreferencesService(preferencesRepository);
	}

	@Override
	public ProjectService newProjectService(ProductFinder finder) {
		return new ProjectService(new TransientRepository<Project, String>(),
				newPreferencesService(), finder);
	}

	/**
	 * returns an instance of the bus. enti. service so we use one during the
	 * unit test cases
	 */
	@Override
	public BusinessEntityService newBusinessEntityService(
			BusinessEntityFinder finder) {

		return new BusinessEntityService(finder);
	}

}
